package com.clstu.homework;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Homework01Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getByName("192.168.1.5"), 9999);//连接服务器端的9999端口。。
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        System.out.println("请输入你要问的问题");
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        bufferedWriter.write(s);
        bufferedWriter.newLine();//表示会话结束
        bufferedWriter.flush();//送数据进数据通道
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        s=bufferedReader.readLine();
        System.out.println("我听道了，你说===="+s);

        bufferedWriter.close();//关闭资源
        bufferedReader.close();
    }
}
